import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CropBatchVO, CropBatchForm, CropBatchQuery } from '@/api/agriculture/cropBatch/types';

/**
 * 查询作物批次列表
 * @param query
 * @returns {*}
 */

export const listCropBatch = (query?: CropBatchQuery): AxiosPromise<CropBatchVO[]> => {
  return request({
    url: '/agriculture/cropBatch/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询作物批次详细
 * @param batchId
 */
export const getCropBatch = (batchId: string | number): AxiosPromise<CropBatchVO> => {
  return request({
    url: '/agriculture/cropBatch/' + batchId,
    method: 'get'
  });
};

/**
 * 新增作物批次
 * @param data
 */
export const addCropBatch = (data: CropBatchForm) => {
  return request({
    url: '/agriculture/cropBatch',
    method: 'post',
    data: data
  });
};

/**
 * 修改作物批次
 * @param data
 */
export const updateCropBatch = (data: CropBatchForm) => {
  return request({
    url: '/agriculture/cropBatch',
    method: 'put',
    data: data
  });
};

/**
 * 删除作物批次
 * @param batchId
 */
export const delCropBatch = (batchId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/cropBatch/' + batchId,
    method: 'delete'
  });
};
